﻿Imports System.Data
Imports System.Data.SqlClient
Public Class evaluacion_clientes
    Sub carga_informacion_empresa()
        Dim cmd As SqlCommand
        Dim q As String
        Try
            Conn.Open()
            cmd = New SqlCommand
            cmd.Connection = Conn
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "sec_consulta_clientes"

            With cmd.Parameters
                .AddWithValue("@ruc", Label3.Text)
            End With
            Dim dr As SqlDataReader = cmd.ExecuteReader
            If dr.Read Then
                TextBox1.Text = dr.Item(2)
                TextBox2.Text = dr.Item(3)
                TextBox3.Text = dr.Item(4)
                TextBox4.Text = dr.Item(4)
                TextBox5.Text = dr.Item(11)
                TextBox6.Text = dr.Item(12)
                TextBox7.Text = dr.Item(10)
                TextBox8.Text = dr.Item(7) & " - " & dr.Item(8)
                TextBox9.Text = FormatNumber(dr.Item(9), NumDigitsAfterDecimal:=2)
                TextBox10.Text = dr.Item(15) & " - " & dr.Item(16)

            Else
                'MessageBox.Show("Data Not Available")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        Conn.Close()
    End Sub
    Sub carga_notas_clientes()
        Dim SQL As String = "select * from Notas where Ruc='" & Label3.Text & "'" & " order by Fecha Desc, Hora Asc"
        Dim da As SqlDataAdapter
        Dim dt As New DataTable
        Try
            da = New SqlDataAdapter(SQL, nCnn)
            da.Fill(dt)
            ListView1.Items.Clear()
            For i = 0 To dt.Rows.Count - 1
                Dim Itm = ListView1.Items.Add(RTrim(dt.Rows(i)("Fecha")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Hora")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Notas")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Usuario")))
            Next
            ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
        Catch ex As Exception
            MsgBox("Error notas: " & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Sub Carga_representantes_clientes()
        Dim SQL As String = "select * from Representantes where Ruc='" & Label3.Text & "'" & " order by Tipo Asc"
        Dim da As SqlDataAdapter
        Dim dt As New DataTable
        Try
            da = New SqlDataAdapter(SQL, nCnn)
            da.Fill(dt)
            ListView2.Items.Clear()
            For i = 0 To dt.Rows.Count - 1
                Dim Itm = ListView2.Items.Add(RTrim(dt.Rows(i)("Tipo")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("DNI")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Nombres")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Participacion")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("DNIConyuge")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("NombreConyuge")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Direccion")))
                Itm.SubItems.Add(RTrim(dt.Rows(i)("Archivo")))
            Next
            ListView2.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
        Catch ex As Exception
            MsgBox("Error representantes: " & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Private Sub evaluacion_clientes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label3.Text = Ruc
        Label4.Text = Cliente
        Label39.Text = Date.Today
        Call Carga_representantes_clientes()
        Call carga_informacion_empresa()
        Call carga_notas_clientes()

    End Sub

    Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click

    End Sub

    Private Sub TextBox24_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox33_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox30_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TabPage3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage3.Click

    End Sub

    Private Sub TextBox38_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox38_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox40_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox40_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox42_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox42_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox42_TextChanged_1(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox44_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

    

    Private Sub TextBox44_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox46_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

    
    Private Sub TextBox46_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox48_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

    

    Private Sub TextBox48_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox50_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

  

    Private Sub TextBox50_ReadOnlyChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox50_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox54_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

  

    Private Sub TextBox54_TextChanged(sender As Object, e As EventArgs)

    End Sub

   

    Private Sub TextBox56_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox56_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox58_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox58_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox60_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox60_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox62_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

   

    Private Sub TextBox62_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox64_KeyPress(sender As Object, e As KeyPressEventArgs)

    End Sub

    

    Private Sub TextBox64_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub TextBox37_TextChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub ListView2_DoubleClick(sender As Object, e As EventArgs) Handles ListView2.DoubleClick
        For i = 0 To ListView2.Items.Count - 1
            If ListView2.Items(i).Selected = True Then
                dni = ListView2.Items(i).SubItems(1).Text
                modifica_clientes.MdiParent = menu_principal
                modifica_clientes.Show()
                Exit For
            End If
        Next
    End Sub

    Private Sub ListView2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView2.SelectedIndexChanged

    End Sub
End Class
